﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CommunitySystem.Ctrls;
using CommunitySystem.EmpbasicService;
using CommunitySystem.PublicOfficialSelectionService;
using CommunitySystem.Views;
using CommunitySystem.ZhaoLuService;
using org.in2bits.MyXls;

namespace CommunitySystem
{
    public partial class ZL_ZhiWeiShiJianAnPaiControl : AsyncCtrl, IReturnListenerc
    {
        #region IReturnListenerc 成员
        public void BeginReturn()
        {
            //Load();
        }
        #endregion
        private ZhaoLuService.ZhaoLuServiceClient Client2 = new ZhaoLuServiceClient();
        private ObservableCollection<ZhaoLuZhiWeiModel> gangweiJH =
            new ObservableCollection<ZhaoLuZhiWeiModel>();
        private PublicOfficialSelectionServiceClient Client1 = new PublicOfficialSelectionServiceClient();
        private ObservableCollection<CommunitySystem.ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel> JH =
            new ObservableCollection<ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel>();
        private ObservableCollection<KaoGuanModel> kaoguanJH = new ObservableCollection<KaoGuanModel>();
        private Dictionary<int, int> intJH = new Dictionary<int, int>();
        private EmpbasicService.EmpBasicServiceClient Client = new EmpbasicService.EmpBasicServiceClient();
        private DateTime? DaoChuRiQi { get; set; }
        public string DaoChuZu { get; set; }
        public ZL_ZhiWeiShiJianAnPaiControl()
        {
            InitializeComponent();
            zucha.DataContext = this;
            for (int i = DateTime.Today.Year; i > DateTime.Today.Year - 10; i--)
            {
                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Content = i.ToString();
                cbi.Tag = i;
                nian.Items.Add(cbi);
            }
            DaoChuRiQi = DateTime.Today;
            DaoChuZu = "第一组";
            DaoChu.Visibility = System.Windows.Visibility.Collapsed;
            riqi11.Visibility = System.Windows.Visibility.Collapsed;
            zucha.Visibility = System.Windows.Visibility.Collapsed;
            DaoChu2.Visibility = System.Windows.Visibility.Collapsed;
            nian.SelectedIndex = 0;
            DGRole.LoadingRow += new EventHandler<DataGridRowEventArgs>(DGRole_LoadingRow);
            LoadData();
            Client.GetOrgForHRModelCompleted += new EventHandler<EmpbasicService.GetOrgForHRModelCompletedEventArgs>(Client_GetOrgForHRModelCompleted);
            Client.GetOrgForHRModelAsync(0);
            Client2.ZL_PublicOfficialSelectionForAnPaiSuoDingCompleted += 
                new EventHandler<ZL_PublicOfficialSelectionForAnPaiSuoDingCompletedEventArgs>(Client1_PublicOfficialSelectionForAnPaiSuoDingCompleted);
            Client2.ZL_GetPublicOfficialSelectionForDaoChuCompleted +=
                new EventHandler<ZL_GetPublicOfficialSelectionForDaoChuCompletedEventArgs>(Client1_GetPublicOfficialSelectionForDaoChuCompleted);
            Client1.GetKaoGuanDetailModelCompleted += new EventHandler<GetKaoGuanDetailModelCompletedEventArgs>(Client1_GetKaoGuanDetailModelCompleted);
            Client2.GetZL_MianShiRenShuCompleted += new EventHandler<GetZL_MianShiRenShuCompletedEventArgs>(Client2_GetZL_MianShiRenShuCompleted);
            Client2.ZL_InsertZuCompleted += new EventHandler<ZL_InsertZuCompletedEventArgs>(Client2_ZL_InsertZuCompleted);
            Client2.ZL_PublicOfficialSelectionForAnPaiCompleted += new EventHandler<ZL_PublicOfficialSelectionForAnPaiCompletedEventArgs>(Client1_PublicOfficialSelectionForAnPaiCompleted);
        }

        void Client2_ZL_InsertZuCompleted(object sender, ZL_InsertZuCompletedEventArgs e)
        {
            if (cou == ((ObservableCollection<ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel>)DGRole.ItemsSource).Count)
            {
                SilverlightMessageBoxLibrary.Message.InfoMessage("保存成功！");
                cou = cou - 1;
                LoadData();
            }
        }
        private void MianShiData_Click1(object sender, RoutedEventArgs e)
        {
            ZhiWeiShiJianAnPaiControl1 view = new ZhiWeiShiJianAnPaiControl1(DateTime.Today.Year - nian.SelectedIndex,
                                                                "招录管理");
            //view.Nav = Nav;
            Nav.ShowNextPage("面试人员信息", view, this);
        }
        void Client2_GetZL_MianShiRenShuCompleted(object sender, GetZL_MianShiRenShuCompletedEventArgs e)
        {
            intJH = e.Result;
        }
        public ObservableCollection<OrgForHRModel> OrgJH = new ObservableCollection<OrgForHRModel>();
        void Client_GetOrgForHRModelCompleted(object sender, EmpbasicService.GetOrgForHRModelCompletedEventArgs e)
        {
            OrgJH = e.Result;
        }
        private bool empassessmentbool = false;
        void Client1_PublicOfficialSelectionForAnPaiCompleted(object sender, ZL_PublicOfficialSelectionForAnPaiCompletedEventArgs e)
        {
            JH = e.Result;
            empassessmentbool = true;
            TryPageInit();
        }
        private bool empassessmentbool2 = false;
        void Client1_GetKaoGuanDetailModelCompleted(object sender, GetKaoGuanDetailModelCompletedEventArgs e)
        {
            kaoguanJH = e.Result;
            empassessmentbool2 = true;
            TryPageInit();
        }
        void zhu_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (KaoGuanModel i in kaoguanJH.Where(p => p.KGType == "主考官"
                && p.XBType == "招录管理"))
            {
                if (((ComboBox)sender).SelectedItem != null)
                    if (i.ID == ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID)
                    {
                        if (((ComboBox)sender).DataContext != null)
                        {
                            i.Zu = ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).Zu;
                            ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).ZhuKaoGuan =
                            ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID;
                        }

                    }
            }
        }
        void zhuan1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (KaoGuanModel i in kaoguanJH.Where(p => p.KGType == "专业考官"
                                                                    &&
                                                                    p.XBType == "招录管理"))
            {
                if (((ComboBox)sender).SelectedItem != null)
                    if (i.ID == ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID)
                    {
                        if (((ComboBox)sender).DataContext != null) i.Zu = ((ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).Zu;
                        if (((ComboBox)sender).DataContext != null && ((ComboBox)sender).SelectedItem != null) ((ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).ZhuanYeKaoGuan1 =
                            ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID;

                    }
            }

            ComboBox dtb = sender as ComboBox;
            var entity = dtb.DataContext as ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel;
            List<object> list = dic[entity];
            int id = 0;
            if (((ComboBox)list[1]).SelectedItem != null)
            {
                id = ((KaoGuanModel)(((ComboBox)list[1]).SelectedItem)).ID;
            }
            ((ComboBox)list[2]).ItemsSource = kaoguanJH.Where(p => p.KGType == "专业考官"
                                                                    &&
                                                                    p.XBType == "招录管理" && p.ID != id);



        }
        void zhuan2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (KaoGuanModel i in kaoguanJH.Where(p => p.KGType == "专业考官"
                                                                    &&
                                                                    p.XBType == "招录管理"))
            {
                if (((ComboBox)sender).SelectedItem != null)
                    if (i.ID == ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID)
                    {
                        if (((ComboBox)sender).DataContext != null) i.Zu = ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).Zu;
                        if (((ComboBox)sender).DataContext != null && ((ComboBox)sender).SelectedItem != null) ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).ZhuanYeKaoGuan2 =
                            ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID;
                    }
            }

        }
        void danwei1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (((ComboBox)sender).DataContext != null && ((ComboBox)sender).SelectedItem != null) ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).DanWeiKaoGuan1 =
                        ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID;
        }
        private void danwei1_DropDown(object sender, System.EventArgs e)
        {
            ComboBox zhukaoguan = (ComboBox)sender;
            zhukaoguan.ItemsSource = kaoguanJH.Where(p => p.KGType == "单位考官"
                && p.XBType == "招录管理");
        }
        void danwei2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (((ComboBox)sender).DataContext != null && ((ComboBox)sender).SelectedItem != null) ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).DanWeiKaoGuan2 =
                        ((KaoGuanModel)(((ComboBox)sender).SelectedItem)).ID;
        }
        private void danwei2_DropDown(object sender, System.EventArgs e)
        {
            ComboBox zhukaoguan = (ComboBox)sender;
            zhukaoguan.ItemsSource = kaoguanJH.Where(p => p.KGType == "单位考官"
                && p.XBType == "招录管理");

        }
        private void TryPageInit()
        {
            if (empassessmentbool == true && empassessmentbool1 == true && empassessmentbool2 == true)
            {

                empassessmentbool = false;
                empassessmentbool1 = false;
                empassessmentbool2 = false;
                PageInit();
            }
        }
        public void PageInit()
        {
            DGRole.ItemsSource = JH;
            if (JH.Count > 0 && JH[0].PublicOfficialSelectionID != 0)
            {
                DaoChu.Visibility = System.Windows.Visibility.Visible;
                riqi11.Visibility = System.Windows.Visibility.Visible;
                zucha.Visibility = System.Windows.Visibility.Visible;
                DaoChu2.Visibility = System.Windows.Visibility.Visible;
            }
        }
        #region 面试时间
        void dpBeginTime_ValueChanged(object sender, RoutedPropertyChangedEventArgs<DateTime?> e)
        {
            ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((TimePicker)sender).DataContext).StartShi = ((TimePicker)sender).Value.Value;
            if (string.IsNullOrEmpty(((ZL_ZhiWeiShiJianAnPaiModel)(((TimePicker)sender).DataContext)).EndShi))
                ((ZL_ZhiWeiShiJianAnPaiModel)((TimePicker)sender).DataContext).EndShi =
                      ((TimePicker)sender).Value.Value.TimeOfDay.Add(new TimeSpan(0,
                          ((ZL_ZhiWeiShiJianAnPaiModel)((TimePicker)sender).DataContext).RenShu * 15, 0)).ToString();

        }

        void dpEndTime_ValueChanged(object sender, RoutedPropertyChangedEventArgs<DateTime?> e)
        {
            //((TimePicker)sender).Value.
            ((ZL_ZhiWeiShiJianAnPaiModel)((TimePicker)sender).DataContext).EndShi = ((TimePicker)sender).Value.Value.ToString();
        }

        #endregion

        private void ChaData_Click(object sender, RoutedEventArgs e)
        {
            LoadData();
        }
        void Client1_PublicOfficialSelectionForAnPaiSuoDingCompleted(object sender, ZL_PublicOfficialSelectionForAnPaiSuoDingCompletedEventArgs e)
        {
            DGRole1.ItemsSource = e.Result;
        }
        public void LoadLieBiaoData()
        {
            Client1.PublicOfficialSelectionForAnPaiSuoDingAsync(DateTime.Today.Year - nian.SelectedIndex,
                                                                "招录管理", "招录管理");

        }
        private int cou = 0;
        private void Data_Click(object sender, RoutedEventArgs e)
        {
            cou = 0;
            foreach (ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel i in DGRole.ItemsSource)
            {
                if (string.IsNullOrEmpty(i.RiQi.ToString()) || i.RiQi.ToString() == "1900/1/1 0:00:00" || string.IsNullOrEmpty(i.Zu) ||
                    i.ZhuKaoGuan == 0 || i.ZhuanYeKaoGuan1 == 0 || i.ZhuanYeKaoGuan2 == 0 || i.DanWeiKaoGuan1 == 0 ||
                    i.DanWeiKaoGuan2 == 0 || string.IsNullOrEmpty(i.MianShiJianDuYuan) || string.IsNullOrEmpty(i.GongZuoRenGuan1)
                    || string.IsNullOrEmpty(i.GongZuoRenGuan2) || string.IsNullOrEmpty(i.StartShi.ToString()) || string.IsNullOrEmpty(i.EndShi))
                {
                    SilverlightMessageBoxLibrary.Message.ErrorMessage("请正确填写日程安排信息！");
                    return;
                }
            }
            foreach (ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel i in DGRole.ItemsSource)
            {
                i.Year = DateTime.Today.Year - nian.SelectedIndex;
                
                Client2.ZL_InsertZuAsync(i, "交流选拔");
                cou += 1;
            }
        }

        private void ViewData_Click(object sender, RoutedEventArgs e)
        {
            var seljw = this.DGRole1.SelectedItem as ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel;
            if (seljw != null)
            {
                ZhiWeiShiJianAnPaiWindow RMWindow = new ZhiWeiShiJianAnPaiWindow(Convert.ToInt32(seljw.ID));
                //RMWindow.Closed += new EventHandler(RMWindow_Closed);
                RMWindow.Show();

            }
            else SilverlightMessageBoxLibrary.Message.ErrorMessage("请选择要查看的记录！");
        }
        void RMWindow_Closed(object sender, EventArgs e)
        {
            LoadLieBiaoData();
        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            NewData.Visibility = System.Windows.Visibility.Collapsed;
            ViewData.Visibility = System.Windows.Visibility.Visible;
            DGRole.Visibility = System.Windows.Visibility.Collapsed;
            DGRole1.Visibility = System.Windows.Visibility.Visible;
            LoadLieBiaoData();
        }

        private void chkHiddenCols_Unchecked(object sender, RoutedEventArgs e)
        {
            NewData.Visibility = System.Windows.Visibility.Visible;
            ViewData.Visibility = System.Windows.Visibility.Collapsed;
            DGRole.Visibility = System.Windows.Visibility.Visible;
            DGRole1.Visibility = System.Windows.Visibility.Collapsed;
            LoadData();
        }

        public Dictionary<ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel, List<object>> dic =
            new Dictionary<ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel, List<object>>();

        void DGRole_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            var entity = (ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)e.Row.DataContext;

            if (!string.IsNullOrEmpty(entity.Zu) && !dic1.Keys.Contains(entity.Zu))
            {
                List<int> ll = new List<int>();
                ll.Add(entity.ZhuKaoGuan);
                ll.Add(entity.ZhuanYeKaoGuan1);
                ll.Add(entity.ZhuanYeKaoGuan2);
                dic1.Add(entity.Zu, ll);
            }

            if (!dic.Keys.Contains(entity))
                dic.Add(entity, new List<object>());
            DictTextBox dtb = this.DGRole.Columns[1].GetCellContent(e.Row) as DictTextBox;
            dtb.OnSelectionChanged += new OnSelectionChangedEvent(dtb_OnSelectionChanged);
            //岗位
            ComboBox gangwei = this.DGRole.Columns[2].GetCellContent(e.Row) as ComboBox;
            gangwei.Tag = e.Row.GetIndex();
            gangwei.ItemsSource = gangweiJH;
            for (int i = 0; i < gangwei.Items.Count; i++)
            {
                if (((ZhaoLuZhiWeiModel)(gangwei.Items[i])).ID
                    == ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)e.Row.DataContext).PublicOfficialSelectionID)
                {
                    gangwei.SelectedIndex = i;
                }
            }

            ComboBox zhukaoguan = this.DGRole.Columns[3].GetCellContent(e.Row) as ComboBox;
            zhukaoguan.Tag = e.Row.GetIndex();
            dic[entity].Add(zhukaoguan);
            zhukaoguan.DataContext = entity;

            ComboBox zhuanye1 = this.DGRole.Columns[4].GetCellContent(e.Row) as ComboBox;
            zhuanye1.Tag = e.Row.GetIndex();
            dic[entity].Add(zhuanye1);
            zhuanye1.DataContext = entity;
            ComboBox zhuanye2 = this.DGRole.Columns[5].GetCellContent(e.Row) as ComboBox;
            zhuanye2.Tag = e.Row.GetIndex();
            dic[entity].Add(zhuanye2);
            zhuanye2.DataContext = entity;
            ComboBox danwei1 = this.DGRole.Columns[6].GetCellContent(e.Row) as ComboBox;
            danwei1.Tag = e.Row.GetIndex();
            danwei1.ItemsSource = kaoguanJH.Where(p => p.KGType == "单位考官"
                && p.XBType == "招录管理");
            for (int i = 0; i < danwei1.Items.Count; i++)
            {
                if (((CommunitySystem.PublicOfficialSelectionService.KaoGuanModel)(danwei1.Items[i])).ID
                    == ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)e.Row.DataContext).DanWeiKaoGuan1)
                {
                    danwei1.SelectedIndex = i;
                }
            }

            ComboBox danwei2 = this.DGRole.Columns[7].GetCellContent(e.Row) as ComboBox;
            danwei2.Tag = e.Row.GetIndex();
            danwei2.ItemsSource = kaoguanJH.Where(p => p.KGType == "单位考官"
                && p.XBType == "招录管理");
            for (int i = 0; i < danwei2.Items.Count; i++)
            {
                if (((CommunitySystem.PublicOfficialSelectionService.KaoGuanModel)(danwei2.Items[i])).ID
                    == ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)e.Row.DataContext).DanWeiKaoGuan2)
                {
                    danwei2.SelectedIndex = i;
                }
            }
            TimePicker start = this.DGRole.Columns[11].GetCellContent(e.Row).FindName("dpBeginTime") as TimePicker;
            start.Tag = e.Row.GetIndex();
            TimePicker end = this.DGRole.Columns[11].GetCellContent(e.Row).FindName("dpEndTime") as TimePicker;
            end.Tag = e.Row.GetIndex();
        }

        Dictionary<string, List<int>> dic1 = new Dictionary<string, List<int>>();
        void dtb_OnSelectionChanged(object sender, object NewValue, object OldValue)
        {
            DictTextBox dtb = sender as DictTextBox;
            var entity = dtb.DataContent as ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel;

            if (OldValue == null)
            {
                foreach (ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel o in ((ObservableCollection<ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel>)DGRole.ItemsSource))
                {
                    if (!string.IsNullOrEmpty(o.Zu) && o.ZhuKaoGuan != 0)
                    {
                        if (!dic1.Keys.Contains(o.Zu))
                        {
                            List<int> ll = new List<int>();
                            ll.Add(o.ZhuKaoGuan);
                            ll.Add(o.ZhuanYeKaoGuan1);
                            ll.Add(o.ZhuanYeKaoGuan2);
                            dic1.Add(o.Zu, ll);
                        }
                    }


                }
            }
            List<object> list = dic[entity];
            List<int> ids = new List<int>();
            foreach (string ss in dic1.Keys)
            {
                ids.Add(dic1[ss][0]);
            }
            int biaozhi = 0;
            if (dic1.Keys.Contains(entity.Zu))
            {
                foreach (ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel o in JH)
                {
                    if (o.RiQi == entity.RiQi && o.Zu == entity.Zu && o.ZhuKaoGuan != 0)
                    {
                        biaozhi = 1;
                        break;
                    }
                }
                if (biaozhi == 1)
                {
                    ((ComboBox)list[0]).ItemsSource = kaoguanJH.Where(p => p.ID == dic1[entity.Zu][0]);
                    if (((ComboBox)list[0]).Items.Count > 0) ((ComboBox)list[0]).SelectedIndex = 0;
                    ((ComboBox)list[1]).ItemsSource = kaoguanJH.Where(p => p.ID == dic1[entity.Zu][1]);
                    if (((ComboBox)list[1]).Items.Count > 0) ((ComboBox)list[1]).SelectedIndex = 0;
                    ((ComboBox)list[2]).ItemsSource = kaoguanJH.Where(p => p.ID == dic1[entity.Zu][2]);
                    if (((ComboBox)list[2]).Items.Count > 0) ((ComboBox)list[2]).SelectedIndex = 0;
                }
                else
                {
                    var collection1 = kaoguanJH.Where(p => p.KGType == "主考官"
            && p.XBType == "招录管理");
                    ((ComboBox)list[0]).ItemsSource = collection1;

                    var collection2 = kaoguanJH.Where(p => p.KGType == "专业考官"
                && p.XBType == "招录管理");
                    ((ComboBox)list[1]).ItemsSource = collection2;

                    ((ComboBox)list[2]).ItemsSource = kaoguanJH.Where(p => p.KGType == "专业考官"
                && p.XBType == "招录管理");
                }

            }
            else
            {
                var collection1 = kaoguanJH.Where(p => p.KGType == "主考官"
            && p.XBType == "招录管理" && !ids.Contains(p.ID));
                ((ComboBox)list[0]).ItemsSource = collection1;

                var collection2 = kaoguanJH.Where(p => p.KGType == "专业考官"
            && p.XBType == "招录管理");
                ((ComboBox)list[1]).ItemsSource = collection2;

                ((ComboBox)list[2]).ItemsSource = kaoguanJH.Where(p => p.KGType == "专业考官"
            && p.XBType == "招录管理");
            }

        }
        private List<int> IsSelectedGangWei = new List<int>();

        void gangwei_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((((ComboBox)sender).SelectedItem) != null)
            {
                IsSelectedGangWei.Add(((ZhaoLuZhiWeiModel)(((ComboBox)sender).SelectedItem)).ID);
                ((ZhaoLuZhiWeiModel)(((ComboBox)sender).SelectedItem)).IsSelected1 = true;
                foreach (var ii in gangweiJH)
                {
                    if (!IsSelectedGangWei.Contains(ii.ID))
                    {
                        ii.IsSelected1 = false;
                    }
                    else ii.IsSelected1 = true;
                }
            }
            if (((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext) != null && (((ComboBox)sender).SelectedItem) != null)
                ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).PublicOfficialSelectionID =
                ((ZhaoLuService.ZhaoLuZhiWeiModel)(((ComboBox)sender).SelectedItem)).ID;
            if (((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext) != null && (((ComboBox)sender).SelectedItem) != null)
                if (intJH != null)
                {
                    foreach (int i in intJH.Keys)
                    {
                        if (((ComboBox)sender).SelectedItem != null && ((ComboBox)sender).DataContext != null)
                            if (i == ((ZhaoLuZhiWeiModel)(((ComboBox)sender).SelectedItem)).ID)
                            {
                                ((ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel)((ComboBox)sender).DataContext).RenShu = intJH[i];
                            }
                    }
                }
        }
        private void gangwei_DropDown(object sender, System.EventArgs e)
        {
            int id = 0;
            object obj = ((ComboBox)sender).SelectedItem;
            if (((ComboBox)sender).SelectedItem != null)
            {
                id = ((ZhaoLuZhiWeiModel)(((ComboBox)sender).SelectedItem)).ID;
                ((ComboBox)sender).ItemsSource = gangweiJH.Where(p => p.IsSelected1 == false || (p.IsSelected1 == true && p.ID == id));
                ((ComboBox)sender).SelectedItem = obj;
            }
            else
                ((ComboBox)sender).ItemsSource = gangweiJH.Where(p => p.IsSelected1 == false);
        }
        private bool empassessmentbool1 = false;
        void Client1_GetPublicOfficialSelectionForDaoChuCompleted(object sender, ZL_GetPublicOfficialSelectionForDaoChuCompletedEventArgs e)
        {
            foreach (ZhaoLuZhiWeiModel i in e.Result)
            {
                i.DutyDes = i.OrgName + "-" + i.Department_Duty + "-" + i.Duty;
            }
            gangweiJH = e.Result;
            empassessmentbool1 = true;
            TryPageInit();
        }
        public void LoadData()
        {
            dic1.Clear();
            dic.Clear();
            if (DateTime.Today.Year - nian.SelectedIndex != DateTime.Today.Year)
                DGRole.IsEnabled = false;
            else DGRole.IsEnabled = true;
            Client2.ZL_PublicOfficialSelectionForAnPaiAsync(DateTime.Today.Year - nian.SelectedIndex, "招录管理");
            //岗位

            Client2.ZL_GetPublicOfficialSelectionForDaoChuAsync(DateTime.Today.Year - nian.SelectedIndex, "0");

            Client1.GetKaoGuanDetailModelAsync("", DateTime.Today.Year - nian.SelectedIndex, 0,"招录工作");


            Client2.GetZL_MianShiRenShuAsync(0, DateTime.Today.Year - nian.SelectedIndex);


        }

        #region
        private Stream DataSheetExport = null;
        private void MianShiData_Click(object sender, RoutedEventArgs e)
        {
            var downLoad = new SaveFileDialog()
            {
                //Filter = "Excel files(2007~2010) (*.xlsx)|*.xlsx|Excel files(2003) (*.xls)|*.xls", //"Excel files (*.xlsx)|*.xlsx|(*.xls)|*.xls",
                Filter = "Excel files(2003) (*.xls)|*.xls",
            };
            if (downLoad.ShowDialog() == true)
            {
                if (((ImageButton)sender).IBTitle == "导出总表")
                {
                    if (JH.Count <= 0)
                    {
                        MessageBox.Show("没有可导出的数据！");
                        return;
                    }
                    DataSheetExport = downLoad.OpenFile();
                    DaoChu1();
                }
                else
                {
                    if (string.IsNullOrEmpty(DaoChuRiQi.ToString()) || DaoChuRiQi == Convert.ToDateTime("1900-01-01") || string.IsNullOrEmpty(DaoChuZu) || string.IsNullOrEmpty(riqi11.Text))
                    {
                        MessageBox.Show("请选择导出日期及组别！");
                        return;
                    }
                    if (JH.Where(p => Convert.ToDateTime(p.RiQi) == Convert.ToDateTime(riqi11.Text) && p.Zu == DaoChuZu).ToList().Count <= 0)
                    {
                        MessageBox.Show("没有可导出的数据！");
                        return;
                    }
                    ObservableCollection<ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel> JH1 =
                    new ObservableCollection<ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel>(JH.Where(p => Convert.ToDateTime(p.RiQi) == Convert.ToDateTime(riqi11.Text) && p.Zu == DaoChuZu));
                    DataSheetExport = downLoad.OpenFile();
                    DaoChuData_Click(JH1);
                }
            }
        }

        public int gonggongriqiint = 0;
        public int gonggongzuint = 0;
        public int gonggongsxwint = 0;
        /// <summary>
        /// 计算星期几
        /// </summary>
        /// <param name="y"></param>
        /// <param name="m"></param>
        /// <param name="d"></param>
        /// <returns></returns>
        public static string CaculateWeekDay(int y, int m, int d)
        {
            if (m == 1) m = 13;
            if (m == 2) m = 14;
            int week = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7 + 1;
            string weekstr = "";
            switch (week)
            {
                case 1:
                    weekstr = "星期一";
                    break;
                case 2:
                    weekstr = "星期二";
                    break;
                case 3:
                    weekstr = "星期三";
                    break;
                case 4:
                    weekstr = "星期四";
                    break;
                case 5:
                    weekstr = "星期五";
                    break;
                case 6:
                    weekstr = "星期六";
                    break;
                case 7:
                    weekstr = "星期日";
                    break;
            }

            return weekstr;
        }
        private void DaoChu1()
        {
            XlsDocument xls = new XlsDocument();
            XF xf = xls.NewXF();
            xf.HorizontalAlignment = HorizontalAlignments.Centered;
            xf.VerticalAlignment = VerticalAlignments.Centered;
            xf.UseBorder = true;
            xf.TopLineStyle = 1;
            xf.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf.BottomLineStyle = 1;
            xf.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf.LeftLineStyle = 1;
            xf.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf.RightLineStyle = 1;
            xf.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf.Font.FontName = "宋体"; // 字体  
            xf.TextWrapRight = true;

            XF xf1 = xls.NewXF();
            xf1.UseBorder = true;
            xf1.TopLineStyle = 1;
            xf1.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.BottomLineStyle = 1;
            xf1.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.LeftLineStyle = 1;
            xf1.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.RightLineStyle = 1;
            xf1.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.HorizontalAlignment = HorizontalAlignments.Centered;
            xf1.VerticalAlignment = VerticalAlignments.Centered;
            xf1.Font.Bold = true;
            xf1.Font.FontName = "黑体"; // 字体  
            xf1.Font.Height = 15 * 20;

            XF xf2 = xls.NewXF();
            xf2.UseBorder = true;
            xf2.TopLineStyle = 1;
            xf2.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.BottomLineStyle = 1;
            xf2.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.LeftLineStyle = 1;
            xf2.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.RightLineStyle = 1;
            xf2.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.HorizontalAlignment = HorizontalAlignments.Centered;
            xf2.VerticalAlignment = VerticalAlignments.Centered;
            xf2.Font.Bold = true;
            xf2.Font.FontName = "黑体"; // 字体  
            xf2.Font.Height = 12 * 20;
            xf2.TextWrapRight = true;

            Worksheet sheet = xls.Workbook.Worksheets.AddNamed("面试日程安排表");

            sheet.Cells.Merge(1, 1, 1, 15);
            sheet.Cells.Add(1, 1, "徐汇区" + (DateTime.Today.Year - nian.SelectedIndex).ToString() + "年公务员招录面试日程安排表", xf1);
            sheet.Cells.Add(2, 1, "日期", xf2);
            sheet.Cells.Add(2, 2, "场次", xf2);
            sheet.Cells.Add(2, 3, "岗位专业", xf2);
            sheet.Cells.Add(2, 4, "主考官", xf2);
            sheet.Cells.Add(2, 5, "考官", xf2);
            sheet.Cells.Add(2, 6, "考官", xf2);
            sheet.Cells.Add(2, 7, "考官", xf2);
            sheet.Cells.Add(2, 8, "考官", xf2);
            sheet.Cells.Merge(2, 2, 5, 8);
            sheet.Cells.Add(2, 9, "面试监督员", xf2);
            sheet.Cells.Add(2, 10, "面试室工作人员", xf2);
            sheet.Cells.Add(2, 11, "面试室工作人员", xf2);
            sheet.Cells.Merge(2, 2, 10, 11);
            sheet.Cells.Add(2, 12, "面试时间", xf2);
            sheet.Cells.Add(2, 13, "面试时间", xf2);
            sheet.Cells.Merge(2, 2, 12, 13);
            sheet.Cells.Add(2, 14, "面试人数", xf2);
            sheet.Cells.Add(2, 15, "面试地点", xf2);
            ColumnInfo colInfo0 = new ColumnInfo(xls, sheet);
            colInfo0.Width = 20 * 256;
            colInfo0.ColumnIndexStart = 0;
            colInfo0.ColumnIndexEnd = 0;
            sheet.AddColumnInfo(colInfo0);

            ColumnInfo colInfo1 = new ColumnInfo(xls, sheet);
            colInfo1.Width = 20 * 256;
            colInfo1.ColumnIndexStart = 1;
            colInfo1.ColumnIndexEnd = 1;
            sheet.AddColumnInfo(colInfo1);

            ColumnInfo colInfo2 = new ColumnInfo(xls, sheet);
            colInfo2.Width = 40 * 256;
            colInfo2.ColumnIndexStart = 2;
            colInfo2.ColumnIndexEnd = 2;
            sheet.AddColumnInfo(colInfo2);

            ColumnInfo colInfo3 = new ColumnInfo(xls, sheet);
            colInfo3.Width = 10 * 256;
            colInfo3.ColumnIndexStart = 3;
            colInfo3.ColumnIndexEnd = 3;
            sheet.AddColumnInfo(colInfo3);

            ColumnInfo colInfo4 = new ColumnInfo(xls, sheet);
            colInfo4.Width = 10 * 256;
            colInfo4.ColumnIndexStart = 4;
            colInfo4.ColumnIndexEnd = 4;
            sheet.AddColumnInfo(colInfo4);

            ColumnInfo colInfo5 = new ColumnInfo(xls, sheet);
            colInfo5.Width = 10 * 256;
            colInfo5.ColumnIndexStart = 5;
            colInfo5.ColumnIndexEnd = 5;
            sheet.AddColumnInfo(colInfo5);

            ColumnInfo colInfo6 = new ColumnInfo(xls, sheet);
            colInfo6.Width = 10 * 256;
            colInfo6.ColumnIndexStart = 6;
            colInfo6.ColumnIndexEnd = 6;
            sheet.AddColumnInfo(colInfo6);

            ColumnInfo colInfo7 = new ColumnInfo(xls, sheet);
            colInfo7.Width = 10 * 256;
            colInfo7.ColumnIndexStart = 7;
            colInfo7.ColumnIndexEnd = 7;
            sheet.AddColumnInfo(colInfo7);

            ColumnInfo colInfo8 = new ColumnInfo(xls, sheet);
            colInfo8.Width = 10 * 256;
            colInfo8.ColumnIndexStart = 8;
            colInfo8.ColumnIndexEnd = 8;
            sheet.AddColumnInfo(colInfo8);

            ColumnInfo colInfo9 = new ColumnInfo(xls, sheet);
            colInfo9.Width = 10 * 256;
            colInfo9.ColumnIndexStart = 9;
            colInfo9.ColumnIndexEnd = 9;
            sheet.AddColumnInfo(colInfo9);

            ColumnInfo colInfo10 = new ColumnInfo(xls, sheet);
            colInfo10.Width = 10 * 256;
            colInfo10.ColumnIndexStart = 10;
            colInfo10.ColumnIndexEnd = 10;
            sheet.AddColumnInfo(colInfo10);

            ColumnInfo colInfo11 = new ColumnInfo(xls, sheet);
            colInfo11.Width = 10 * 256;
            colInfo11.ColumnIndexStart = 11;
            colInfo11.ColumnIndexEnd = 11;
            sheet.AddColumnInfo(colInfo11);

            ColumnInfo colInfo12 = new ColumnInfo(xls, sheet);
            colInfo12.Width = 20 * 256;
            colInfo12.ColumnIndexStart = 12;
            colInfo12.ColumnIndexEnd = 12;
            sheet.AddColumnInfo(colInfo12);

            ColumnInfo colInfo13 = new ColumnInfo(xls, sheet);
            colInfo13.Width = 6 * 256;
            colInfo13.ColumnIndexStart = 13;
            colInfo13.ColumnIndexEnd = 13;
            sheet.AddColumnInfo(colInfo13);

            ColumnInfo colInfo14 = new ColumnInfo(xls, sheet);
            colInfo14.Width = 10 * 256;
            colInfo14.ColumnIndexStart = 14;
            colInfo14.ColumnIndexEnd = 14;
            sheet.AddColumnInfo(colInfo14);

            ColumnInfo colInfo15 = new ColumnInfo(xls, sheet);
            colInfo15.Width = 10 * 256;
            colInfo15.ColumnIndexStart = 15;
            colInfo15.ColumnIndexEnd = 15;
            sheet.AddColumnInfo(colInfo15);

            foreach (ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel o in JH)
            {
                if (o.PublicOfficialSelectionID == 0 || o.ZhuKaoGuan == 0 || o.ZhuanYeKaoGuan1 == 0 || o.ZhuanYeKaoGuan2 == 0
                    || o.DanWeiKaoGuan1 == 0 || o.DanWeiKaoGuan2 == 0)
                {
                    continue;
                }
                o.Duty = OrgJH.Where(pp => pp.ID == gangweiJH.Where(p => p.ID == o.PublicOfficialSelectionID).FirstOrDefault().OrgID).FirstOrDefault().Name
                    + "--" + gangweiJH.Where(p => p.ID == o.PublicOfficialSelectionID).FirstOrDefault().Duty;
                o.ZhuKaoGuanS = kaoguanJH.Where(p => p.ID == o.ZhuKaoGuan).FirstOrDefault().Name;
                o.ZhuanYeKaoGuan1S = kaoguanJH.Where(p => p.ID == o.ZhuanYeKaoGuan1).FirstOrDefault().Name;
                o.ZhuanYeKaoGuan2S = kaoguanJH.Where(p => p.ID == o.ZhuanYeKaoGuan2).FirstOrDefault().Name;
                o.DanWeiKaoGuan1S = kaoguanJH.Where(p => p.ID == o.DanWeiKaoGuan1).FirstOrDefault().Name;
                o.DanWeiKaoGuan2S = kaoguanJH.Where(p => p.ID == o.DanWeiKaoGuan2).FirstOrDefault().Name;
            }
            if (JH.Count > 0)
            {
                for (int i = 0; i < JH.Count; i++)
                {

                    if (!string.IsNullOrEmpty(JH[i].RiQi.ToString())) sheet.Cells.Add(i + 3, 1, Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd"), xf); else sheet.Cells.Add(i + 3, 1, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].Zu)) sheet.Cells.Add(i + 3, 2, JH[i].Zu.ToString(), xf); else sheet.Cells.Add(i + 3, 2, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].Duty)) sheet.Cells.Add(i + 3, 3, JH[i].Duty.ToString(), xf); else sheet.Cells.Add(i + 3, 3, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].ZhuKaoGuanS)) sheet.Cells.Add(i + 3, 4, JH[i].ZhuKaoGuanS.ToString(), xf); else sheet.Cells.Add(i + 3, 4, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].ZhuanYeKaoGuan1S)) sheet.Cells.Add(i + 3, 5, JH[i].ZhuanYeKaoGuan1S.ToString(), xf); else sheet.Cells.Add(i + 3, 5, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].ZhuanYeKaoGuan2S)) sheet.Cells.Add(i + 3, 6, JH[i].ZhuanYeKaoGuan2S.ToString(), xf); else sheet.Cells.Add(i + 3, 6, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].DanWeiKaoGuan1S)) sheet.Cells.Add(i + 3, 7, JH[i].DanWeiKaoGuan1S.ToString(), xf); else sheet.Cells.Add(i + 3, 7, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].DanWeiKaoGuan2S)) sheet.Cells.Add(i + 3, 8, JH[i].DanWeiKaoGuan2S.ToString(), xf); else sheet.Cells.Add(i + 3, 8, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].MianShiJianDuYuan)) sheet.Cells.Add(i + 3, 9, JH[i].MianShiJianDuYuan.ToString(), xf); else sheet.Cells.Add(i + 3, 9, "", xf);

                    if (!string.IsNullOrEmpty(JH[i].GongZuoRenGuan1)) sheet.Cells.Add(i + 3, 10, JH[i].GongZuoRenGuan1.ToString(), xf); else sheet.Cells.Add(i + 3, 10, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].GongZuoRenGuan2)) sheet.Cells.Add(i + 3, 11, JH[i].GongZuoRenGuan2.ToString(), xf); else sheet.Cells.Add(i + 3, 11, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].EndShi))
                    {
                        if (Convert.ToDateTime(JH[i].EndShi).Hour < 13)
                        {
                            sheet.Cells.Add(i + 3, 12, "上午," + JH[i].RenShu.ToString(), xf);
                            JH[i].SXWU = "上午," + JH[i].RenShu.ToString();
                        }
                        else
                        {
                            sheet.Cells.Add(i + 3, 12, "下午," + JH[i].RenShu.ToString(), xf);
                            JH[i].SXWU = "下午," + JH[i].RenShu.ToString();
                        }
                    }
                    if (!string.IsNullOrEmpty(JH[i].StartShi.ToString()) && !string.IsNullOrEmpty(JH[i].EndShi))
                    {
                        string tem = "";
                        string tem1 = "";
                        if (Convert.ToDateTime(JH[i].StartShi).Minute.ToString() == "0")
                            tem = "00";
                        else tem = Convert.ToDateTime(JH[i].StartShi).Minute.ToString();
                        if (Convert.ToDateTime(JH[i].EndShi).Minute.ToString() == "0")
                            tem1 = "00";
                        else tem1 = Convert.ToDateTime(JH[i].EndShi).Minute.ToString();
                        sheet.Cells.Add(i + 3, 13, Convert.ToDateTime(JH[i].StartShi).Hour.ToString() + ":" + tem + "--" +
                            Convert.ToDateTime(JH[i].EndShi).Hour.ToString() + ":" + tem1, xf);
                    }
                    else sheet.Cells.Add(i + 3, 13, "", xf);

                    if (!string.IsNullOrEmpty(JH[i].RenShu.ToString())) sheet.Cells.Add(i + 3, 14, JH[i].RenShu.ToString(), xf); else sheet.Cells.Add(i + 3, 14, "", xf);
                    if (!string.IsNullOrEmpty(JH[i].DiDian)) sheet.Cells.Add(i + 3, 15, JH[i].DiDian.ToString(), xf); else sheet.Cells.Add(i + 3, 15, "", xf);


                }
                //Dictionary<string, int> dic = new Dictionary<string, int>();
                Dictionary<string, List<string>> dic1 = new Dictionary<string, List<string>>();
                List<string> riqistring = new List<string>();
                for (int i = 0; i < JH.Count; i++)
                {
                    //if(i == 0)
                    //{
                    //    riqistring.Add(Convert.ToDateTime(JH[0].RiQi).ToString("yyyy-MM-dd"));
                    //    dic1.Add(Convert.ToDateTime(JH[0].RiQi).ToString("yyyy-MM-dd"), new List<string>() {JH[0].Zu});
                    //}
                    //else
                    //{
                    //    if(!riqistring.Contains(Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd")))
                    //    {
                    //        riqistring.Add(Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd"));
                    //        dic1[Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd")].Add(JH[i].Zu);
                    //    }
                    //    else
                    //    {
                    //        if(!dic1[Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd")].Contains(JH[i].Zu))
                    //        {
                    //            dic1[Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd")].Add(JH[i].Zu);
                    //        }
                    //    }
                    //}

                    //if (JH[i - 1].Zu == JH[i - 2].Zu && JH[i - 1].Zu != null)
                    //{
                    //    sheet.Cells.Merge(i + 2, i + 1, 2, 2);
                    //    sheet.Cells.Merge(i + 2, i + 1, 4, 4);
                    //    sheet.Cells.Merge(i + 2, i + 1, 5, 5);
                    //    sheet.Cells.Merge(i + 2, i + 1, 6, 6);
                    //    sheet.Cells.Merge(i + 2, i + 1, 9, 9);
                    //    sheet.Cells.Merge(i + 2, i + 1, 10, 10);
                    //    sheet.Cells.Merge(i + 2, i + 1, 11, 11);
                    //    if (JH[i - 1].SXWU != null)
                    //        if (JH[i - 1].SXWU.Split('：')[0] == JH[i - 2].SXWU.Split('：')[0])
                    //        {
                    //            sheet.Cells.Merge(i + 2, i + 1, 12, 12);
                    //            //gonggongsxwint = i + 2;

                    //            sheet.Rows[Convert.ToUInt16(i + 1)].GetCell(Convert.ToUInt16(12)).Value = JH[i - 1].SXWU + (
                    //                Convert.ToInt32(JH[i - 1].SXWU.Split('：')[1]) + Convert.ToInt32(JH[i - 2].SXWU.Split('：')[1]).ToString()) + "人";
                    //        }
                    //}


                }
                int sint2 = 3;
                int eint2 = 0;
                int renshu = 0;
                //合并上下午
                for (int i = 0; i < JH.Count - 1; i++)
                {
                    if (Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd") == Convert.ToDateTime(JH[i + 1].RiQi).ToString("yyyy-MM-dd") &&
                        JH[i].RiQi != null)
                    {
                        if (JH[i].Zu == JH[i + 1].Zu)
                        {
                            if (JH[i].SXWU.Split(',')[0] == JH[i + 1].SXWU.Split(',')[0])
                            {
                                eint2 = i + 4;
                                renshu = renshu + Convert.ToInt32(JH[i].SXWU.Split(',')[1]);
                                if (i == JH.Count - 2)
                                {
                                    sheet.Cells.Merge(sint2, eint2, 12, 12);
                                    sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(12)).Value = JH[i].SXWU.Split(',')[0] + (
                                                Convert.ToInt32(JH[i].SXWU.Split(',')[1]) + Convert.ToInt32(JH[i + 1].SXWU.Split(',')[1])).ToString() + "人";
                                }
                            }
                            else
                            {
                                sheet.Cells.Merge(sint2, eint2, 12, 12);
                                sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(12)).Value = JH[i].SXWU.Split(',')[0] + (
                                                Convert.ToInt32(JH[i].SXWU.Split(',')[1]) + renshu) + "人";

                                if (i == JH.Count - 2)
                                {
                                    sheet.Cells.Merge(sint2 + 1, eint2 + 1, 12, 12);
                                    sheet.Rows[Convert.ToUInt16(sint2 + 1)].GetCell(Convert.ToUInt16(12)).Value = JH[i + 1].SXWU.Split(',')[0] + (
                                                renshu + Convert.ToInt32(JH[i + 1].SXWU.Split(',')[1])) + "人";
                                }
                                else
                                {
                                    sint2 = eint2 + 1;
                                }
                            }
                        }
                        else
                        {
                            sheet.Cells.Merge(sint2, eint2, 12, 12);
                            sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(12)).Value = JH[i].SXWU.Split(',')[0] + (
                                        Convert.ToInt32(JH[i].SXWU.Split(',')[1]) + renshu).ToString() + "人";
                            renshu = 0;
                            sint2 = eint2 + 1;
                            eint2 += 1;
                        }
                    }
                    else
                    {
                        sheet.Cells.Merge(sint2, eint2, 12, 12);
                        sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(12)).Value = JH[i].SXWU.Split(',')[0] + (
                                        Convert.ToInt32(JH[i].SXWU.Split(',')[1]) + renshu).ToString() + "人";
                        sint2 += 1;
                        eint2 += 1;
                    }
                }
                int sint = 3;
                int eint = 0;
                //合并组
                for (int i = 0; i < JH.Count - 1; i++)
                {
                    if (Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd") == Convert.ToDateTime(JH[i + 1].RiQi).ToString("yyyy-MM-dd") &&
                        JH[i].RiQi != null)
                    {
                        if (JH[i].Zu == JH[i + 1].Zu)
                        {
                            eint = i + 4;
                            if (i == JH.Count - 2)
                            {
                                sheet.Cells.Merge(sint, eint, 2, 2);
                                sheet.Cells.Merge(sint, eint, 4, 4);
                                sheet.Cells.Merge(sint, eint, 5, 5);
                                sheet.Cells.Merge(sint, eint, 6, 6);
                                sheet.Cells.Merge(sint, eint, 9, 9);
                                sheet.Cells.Merge(sint, eint, 10, 10);
                                sheet.Cells.Merge(sint, eint, 11, 11);
                                sheet.Cells.Merge(sint, eint, 15, 15);
                            }
                        }
                        else
                        {
                            sheet.Cells.Merge(sint, eint, 2, 2);
                            sheet.Cells.Merge(sint, eint, 4, 4);
                            sheet.Cells.Merge(sint, eint, 5, 5);
                            sheet.Cells.Merge(sint, eint, 6, 6);
                            sheet.Cells.Merge(sint, eint, 9, 9);
                            sheet.Cells.Merge(sint, eint, 10, 10);
                            sheet.Cells.Merge(sint, eint, 11, 11);
                            sheet.Cells.Merge(sint, eint, 15, 15);
                            sint = eint + 1;
                        }
                    }
                    else
                        sint += 1;
                }
                //合并日期
                int sint1 = 3;
                int eint1 = 0;
                for (int i = 0; i < JH.Count - 1; i++)
                {
                    if (Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd") == Convert.ToDateTime(JH[i + 1].RiQi).ToString("yyyy-MM-dd") &&
                        JH[i].RiQi != null)
                    {
                        eint1 = i + 1 + 3;
                        if (i == JH.Count - 2)
                        {
                            sheet.Cells.Merge(sint1, eint1, 1, 1);
                        }
                    }
                    else
                    {
                        sheet.Cells.Merge(sint1, eint1, 1, 1);
                        sint1 = eint1 + 1;
                    }
                }

                xls.Save(DataSheetExport);
                DataSheetExport.Close();
                DataSheetExport.Dispose();
                SilverlightMessageBoxLibrary.Message.InfoMessage("导出成功");
            }
        }
        private void DaoChuData_Click(ObservableCollection<CommunitySystem.ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel> JH1)
        {

            int zongrenshu = 0;
            foreach (CommunitySystem.ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel ii in JH1)
            {
                zongrenshu += Convert.ToInt32(ii.RenShu);
            }
            XlsDocument xls = new XlsDocument();
            XF xf = xls.NewXF();
            xf.HorizontalAlignment = HorizontalAlignments.Centered;
            xf.VerticalAlignment = VerticalAlignments.Centered;
            xf.UseBorder = true;
            xf.TopLineStyle = 1;
            xf.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf.BottomLineStyle = 1;
            xf.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf.LeftLineStyle = 1;
            xf.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf.RightLineStyle = 1;
            xf.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf.Font.FontName = "宋体"; // 字体  
            xf.TextWrapRight = true;

            XF xf1 = xls.NewXF();
            xf1.UseBorder = true;
            xf1.TopLineStyle = 1;
            xf1.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.BottomLineStyle = 1;
            xf1.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.LeftLineStyle = 1;
            xf1.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.RightLineStyle = 1;
            xf1.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.HorizontalAlignment = HorizontalAlignments.Centered;
            xf1.VerticalAlignment = VerticalAlignments.Centered;
            xf1.Font.Bold = true;
            xf1.Font.FontName = "黑体"; // 字体  
            xf1.Font.Height = 15 * 20;

            XF xf2 = xls.NewXF();
            xf2.UseBorder = true;
            xf2.TopLineStyle = 1;
            xf2.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.BottomLineStyle = 1;
            xf2.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.LeftLineStyle = 1;
            xf2.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.RightLineStyle = 1;
            xf2.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.HorizontalAlignment = HorizontalAlignments.Centered;
            xf2.VerticalAlignment = VerticalAlignments.Centered;
            xf2.Font.Bold = true;
            xf2.Font.FontName = "黑体"; // 字体  
            xf2.Font.Height = 12 * 20;
            xf2.TextWrapRight = true;

            Worksheet sheet = xls.Workbook.Worksheets.AddNamed("面试日程安排表");

            sheet.Cells.Merge(1, 1, 1, 14);
            sheet.Cells.Add(1, 1, "徐汇区" + (DateTime.Today.Year - nian.SelectedIndex).ToString() + "年公务员招录面试日程安排表（" + Convert.ToDateTime(riqi11.Text).Month + "月" +
                                                             Convert.ToDateTime(riqi11.Text).Day + "日，" +
                                                            CaculateWeekDay(Convert.ToDateTime(riqi11.Text).Year, Convert.ToDateTime(riqi11.Text).Month,
                                                            Convert.ToDateTime(riqi11.Text).Day) + "【" + DaoChuZu + " " + zongrenshu.ToString() + "人】）", xf1);
            //sheet.Cells.Add(2, 1, "日期", xf2);
            sheet.Cells.Add(2, 1, "场次", xf2);
            sheet.Cells.Add(2, 2, "岗位专业", xf2);
            sheet.Cells.Add(2, 3, "主考官", xf2);
            sheet.Cells.Add(2, 4, "考官", xf2);
            sheet.Cells.Add(2, 5, "考官", xf2);
            sheet.Cells.Add(2, 6, "考官", xf2);
            sheet.Cells.Add(2, 7, "考官", xf2);
            sheet.Cells.Merge(2, 2, 4, 7);
            sheet.Cells.Add(2, 8, "面试监督员", xf2);
            sheet.Cells.Add(2, 9, "面试室工作人员", xf2);
            sheet.Cells.Add(2, 10, "面试室工作人员", xf2);
            sheet.Cells.Merge(2, 2, 9, 10);
            sheet.Cells.Add(2, 11, "面试时间", xf2);
            sheet.Cells.Add(2, 12, "面试时间", xf2);
            sheet.Cells.Merge(2, 2, 11, 12);
            sheet.Cells.Add(2, 13, "面试人数", xf2);
            sheet.Cells.Add(2, 14, "面试地点", xf2);
            //ColumnInfo colInfo0 = new ColumnInfo(xls, sheet);
            //colInfo0.Width = 20 * 256;
            //colInfo0.ColumnIndexStart = 0;
            //colInfo0.ColumnIndexEnd = 0;
            //sheet.AddColumnInfo(colInfo0);

            ColumnInfo colInfo1 = new ColumnInfo(xls, sheet);
            colInfo1.Width = 20 * 256;
            colInfo1.ColumnIndexStart = 0;
            colInfo1.ColumnIndexEnd = 0;
            sheet.AddColumnInfo(colInfo1);

            ColumnInfo colInfo2 = new ColumnInfo(xls, sheet);
            colInfo2.Width = 40 * 256;
            colInfo2.ColumnIndexStart = 1;
            colInfo2.ColumnIndexEnd = 1;
            sheet.AddColumnInfo(colInfo2);

            ColumnInfo colInfo3 = new ColumnInfo(xls, sheet);
            colInfo3.Width = 10 * 256;
            colInfo3.ColumnIndexStart = 2;
            colInfo3.ColumnIndexEnd = 2;
            sheet.AddColumnInfo(colInfo3);

            ColumnInfo colInfo4 = new ColumnInfo(xls, sheet);
            colInfo4.Width = 10 * 256;
            colInfo4.ColumnIndexStart = 3;
            colInfo4.ColumnIndexEnd = 3;
            sheet.AddColumnInfo(colInfo4);

            ColumnInfo colInfo5 = new ColumnInfo(xls, sheet);
            colInfo5.Width = 10 * 256;
            colInfo5.ColumnIndexStart = 4;
            colInfo5.ColumnIndexEnd = 4;
            sheet.AddColumnInfo(colInfo5);

            ColumnInfo colInfo6 = new ColumnInfo(xls, sheet);
            colInfo6.Width = 10 * 256;
            colInfo6.ColumnIndexStart = 5;
            colInfo6.ColumnIndexEnd = 5;
            sheet.AddColumnInfo(colInfo6);

            ColumnInfo colInfo7 = new ColumnInfo(xls, sheet);
            colInfo7.Width = 10 * 256;
            colInfo7.ColumnIndexStart = 6;
            colInfo7.ColumnIndexEnd = 6;
            sheet.AddColumnInfo(colInfo7);

            ColumnInfo colInfo8 = new ColumnInfo(xls, sheet);
            colInfo8.Width = 10 * 256;
            colInfo8.ColumnIndexStart = 7;
            colInfo8.ColumnIndexEnd = 7;
            sheet.AddColumnInfo(colInfo8);

            ColumnInfo colInfo9 = new ColumnInfo(xls, sheet);
            colInfo9.Width = 10 * 256;
            colInfo9.ColumnIndexStart = 8;
            colInfo9.ColumnIndexEnd = 8;
            sheet.AddColumnInfo(colInfo9);

            ColumnInfo colInfo10 = new ColumnInfo(xls, sheet);
            colInfo10.Width = 10 * 256;
            colInfo10.ColumnIndexStart = 9;
            colInfo10.ColumnIndexEnd = 9;
            sheet.AddColumnInfo(colInfo10);

            ColumnInfo colInfo11 = new ColumnInfo(xls, sheet);
            colInfo11.Width = 10 * 256;
            colInfo11.ColumnIndexStart = 10;
            colInfo11.ColumnIndexEnd = 10;
            sheet.AddColumnInfo(colInfo11);

            ColumnInfo colInfo12 = new ColumnInfo(xls, sheet);
            colInfo12.Width = 20 * 256;
            colInfo12.ColumnIndexStart = 11;
            colInfo12.ColumnIndexEnd = 11;
            sheet.AddColumnInfo(colInfo12);

            ColumnInfo colInfo13 = new ColumnInfo(xls, sheet);
            colInfo13.Width = 6 * 256;
            colInfo13.ColumnIndexStart = 12;
            colInfo13.ColumnIndexEnd = 12;
            sheet.AddColumnInfo(colInfo13);

            ColumnInfo colInfo14 = new ColumnInfo(xls, sheet);
            colInfo14.Width = 10 * 256;
            colInfo14.ColumnIndexStart = 13;
            colInfo14.ColumnIndexEnd = 13;
            sheet.AddColumnInfo(colInfo14);

            ColumnInfo colInfo15 = new ColumnInfo(xls, sheet);
            colInfo15.Width = 10 * 256;
            colInfo15.ColumnIndexStart = 14;
            colInfo15.ColumnIndexEnd = 14;
            sheet.AddColumnInfo(colInfo15);

            foreach (ZhaoLuService.ZL_ZhiWeiShiJianAnPaiModel o in JH1)
            {
                if (o.PublicOfficialSelectionID == 0 || o.ZhuKaoGuan == 0 || o.ZhuanYeKaoGuan1 == 0 || o.ZhuanYeKaoGuan2 == 0
                    || o.DanWeiKaoGuan1 == 0 || o.DanWeiKaoGuan2 == 0)
                {
                    continue;
                }
                o.Duty = OrgJH.Where(pp => pp.ID == gangweiJH.Where(p => p.ID == o.PublicOfficialSelectionID).FirstOrDefault().OrgID).FirstOrDefault().Name
                    + "--" + gangweiJH.Where(p => p.ID == o.PublicOfficialSelectionID).FirstOrDefault().Duty;
                o.ZhuKaoGuanS = kaoguanJH.Where(p => p.ID == o.ZhuKaoGuan).FirstOrDefault().Name;
                o.ZhuanYeKaoGuan1S = kaoguanJH.Where(p => p.ID == o.ZhuanYeKaoGuan1).FirstOrDefault().Name;
                o.ZhuanYeKaoGuan2S = kaoguanJH.Where(p => p.ID == o.ZhuanYeKaoGuan2).FirstOrDefault().Name;
                o.DanWeiKaoGuan1S = kaoguanJH.Where(p => p.ID == o.DanWeiKaoGuan1).FirstOrDefault().Name;
                o.DanWeiKaoGuan2S = kaoguanJH.Where(p => p.ID == o.DanWeiKaoGuan2).FirstOrDefault().Name;
            }
            if (JH1.Count > 0)
            {
                for (int i = 0; i < JH1.Count; i++)
                {

                    //if (!string.IsNullOrEmpty(JH1[i].RiQi.ToString())) sheet.Cells.Add(i + 3, 1, Convert.ToDateTime(JH1[i].RiQi).ToString("yyyy-MM-dd"), xf); else sheet.Cells.Add(i + 3, 1, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].Zu)) sheet.Cells.Add(i + 3, 1, DaoChuZu, xf); else sheet.Cells.Add(i + 3, 1, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].Duty)) sheet.Cells.Add(i + 3, 2, JH1[i].Duty.ToString(), xf); else sheet.Cells.Add(i + 3, 2, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].ZhuKaoGuanS)) sheet.Cells.Add(i + 3, 3, JH1[i].ZhuKaoGuanS.ToString(), xf); else sheet.Cells.Add(i + 3, 3, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].ZhuanYeKaoGuan1S)) sheet.Cells.Add(i + 3, 4, JH1[i].ZhuanYeKaoGuan1S.ToString(), xf); else sheet.Cells.Add(i + 3, 4, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].ZhuanYeKaoGuan2S)) sheet.Cells.Add(i + 3, 5, JH1[i].ZhuanYeKaoGuan2S.ToString(), xf); else sheet.Cells.Add(i + 3, 5, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].DanWeiKaoGuan1S)) sheet.Cells.Add(i + 3, 6, JH1[i].DanWeiKaoGuan1S.ToString(), xf); else sheet.Cells.Add(i + 3, 6, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].DanWeiKaoGuan2S)) sheet.Cells.Add(i + 3, 7, JH1[i].DanWeiKaoGuan2S.ToString(), xf); else sheet.Cells.Add(i + 3, 7, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].MianShiJianDuYuan)) sheet.Cells.Add(i + 3, 8, JH1[i].MianShiJianDuYuan.ToString(), xf); else sheet.Cells.Add(i + 3, 8, "", xf);

                    if (!string.IsNullOrEmpty(JH1[i].GongZuoRenGuan1)) sheet.Cells.Add(i + 3, 9, JH1[i].GongZuoRenGuan1.ToString(), xf); else sheet.Cells.Add(i + 3, 9, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].GongZuoRenGuan2)) sheet.Cells.Add(i + 3, 10, JH1[i].GongZuoRenGuan2.ToString(), xf); else sheet.Cells.Add(i + 3, 10, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].EndShi))
                    {
                        if (Convert.ToDateTime(JH1[i].EndShi).Hour < 13)
                        {
                            sheet.Cells.Add(i + 3, 11, "上午," + JH1[i].RenShu.ToString(), xf);
                            JH1[i].SXWU = "上午," + JH[i].RenShu.ToString();
                        }
                        else
                        {
                            sheet.Cells.Add(i + 3, 11, "下午," + JH1[i].RenShu.ToString(), xf);
                            JH1[i].SXWU = "下午," + JH1[i].RenShu.ToString();
                        }
                    }
                    if (!string.IsNullOrEmpty(JH1[i].StartShi.ToString()) && !string.IsNullOrEmpty(JH1[i].EndShi))
                    {
                        string tem = "";
                        string tem1 = "";
                        if (Convert.ToDateTime(JH1[i].StartShi).Minute.ToString() == "0")
                            tem = "00";
                        else tem = Convert.ToDateTime(JH1[i].StartShi).Minute.ToString();
                        if (Convert.ToDateTime(JH1[i].EndShi).Minute.ToString() == "0")
                            tem1 = "00";
                        else tem1 = Convert.ToDateTime(JH1[i].EndShi).Minute.ToString();
                        sheet.Cells.Add(i + 3, 12, Convert.ToDateTime(JH1[i].StartShi).Hour.ToString() + ":" + tem + "--" +
                            Convert.ToDateTime(JH1[i].EndShi).Hour.ToString() + ":" + tem1, xf);
                    }
                    else sheet.Cells.Add(i + 3, 12, "", xf);

                    if (!string.IsNullOrEmpty(JH1[i].RenShu.ToString())) sheet.Cells.Add(i + 3, 13, JH1[i].RenShu.ToString(), xf); else sheet.Cells.Add(i + 3, 13, "", xf);
                    if (!string.IsNullOrEmpty(JH1[i].DiDian)) sheet.Cells.Add(i + 3, 14, JH1[i].DiDian.ToString(), xf); else sheet.Cells.Add(i + 3, 14, "", xf);


                }
                //Dictionary<string, int> dic = new Dictionary<string, int>();
                Dictionary<string, List<string>> dic1 = new Dictionary<string, List<string>>();
                List<string> riqistring = new List<string>();
                int sint2 = 3;
                int eint2 = 0;
                int renshu = 0;
                //合并上下午
                for (int i = 0; i < JH1.Count - 1; i++)
                {
                    if (Convert.ToDateTime(JH1[i].RiQi).ToString("yyyy-MM-dd") == Convert.ToDateTime(JH1[i + 1].RiQi).ToString("yyyy-MM-dd") &&
                        JH1[i].RiQi != null)
                    {
                        if (JH1[i].Zu == JH1[i + 1].Zu)
                        {
                            if (JH1[i].SXWU.Split(',')[0] == JH1[i + 1].SXWU.Split(',')[0])
                            {
                                eint2 = i + 4;
                                renshu = renshu + Convert.ToInt32(JH1[i].SXWU.Split(',')[1]);
                                if (i == JH1.Count - 2)
                                {
                                    sheet.Cells.Merge(sint2, eint2, 11, 11);
                                    sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(11)).Value = JH1[i].SXWU.Split(',')[0] + (
                                                Convert.ToInt32(JH1[i].SXWU.Split(',')[1]) + Convert.ToInt32(JH1[i + 1].SXWU.Split(',')[1])).ToString() + "人";
                                }
                            }
                            else
                            {
                                sheet.Cells.Merge(sint2, eint2, 11, 11);
                                sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(11)).Value = JH1[i].SXWU.Split(',')[0] + (
                                                Convert.ToInt32(JH1[i].SXWU.Split(',')[1]) + renshu) + "人";

                                if (i == JH1.Count - 2)
                                {
                                    sheet.Cells.Merge(sint2 + 1, eint2 + 1, 11, 11);
                                    sheet.Rows[Convert.ToUInt16(sint2 + 1)].GetCell(Convert.ToUInt16(11)).Value = JH1[i + 1].SXWU.Split(',')[0] + (
                                                renshu + Convert.ToInt32(JH1[i + 1].SXWU.Split(',')[1])) + "人";
                                }
                                else
                                {
                                    sint2 = eint2 + 1;
                                }
                            }
                        }
                        else
                        {
                            sheet.Cells.Merge(sint2, eint2, 11, 11);
                            sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(11)).Value = JH1[i].SXWU.Split(',')[0] + (
                                        Convert.ToInt32(JH1[i].SXWU.Split(',')[1]) + renshu).ToString() + "人";
                            renshu = 0;
                            sint2 = eint2 + 1;
                            eint2 += 1;
                        }
                    }
                    else
                    {
                        sheet.Cells.Merge(sint2, eint2, 11, 11);
                        sheet.Rows[Convert.ToUInt16(sint2)].GetCell(Convert.ToUInt16(11)).Value = JH1[i].SXWU.Split(',')[0] + (
                                        Convert.ToInt32(JH1[i].SXWU.Split(',')[1]) + renshu).ToString() + "人";
                        sint2 += 1;
                        eint2 += 1;
                    }
                }
                int sint = 3;
                int eint = 0;
                //合并组
                for (int i = 0; i < JH1.Count - 1; i++)
                {
                    if (Convert.ToDateTime(JH1[i].RiQi).ToString("yyyy-MM-dd") == Convert.ToDateTime(JH1[i + 1].RiQi).ToString("yyyy-MM-dd") &&
                        JH1[i].RiQi != null)
                    {
                        if (JH1[i].Zu == JH1[i + 1].Zu)
                        {
                            eint = i + 4;
                            if (i == JH1.Count - 2)
                            {
                                sheet.Cells.Merge(sint, eint, 1, 1);
                                sheet.Cells.Merge(sint, eint, 3, 3);
                                sheet.Cells.Merge(sint, eint, 4, 4);
                                sheet.Cells.Merge(sint, eint, 5, 5);
                                sheet.Cells.Merge(sint, eint, 8, 8);
                                sheet.Cells.Merge(sint, eint, 9, 9);
                                sheet.Cells.Merge(sint, eint, 10, 10);
                                sheet.Cells.Merge(sint, eint, 14, 14);
                            }
                        }
                        else
                        {
                            sheet.Cells.Merge(sint, eint, 1, 1);
                            sheet.Cells.Merge(sint, eint, 3, 3);
                            sheet.Cells.Merge(sint, eint, 4, 4);
                            sheet.Cells.Merge(sint, eint, 5, 5);
                            sheet.Cells.Merge(sint, eint, 8, 8);
                            sheet.Cells.Merge(sint, eint, 9, 9);
                            sheet.Cells.Merge(sint, eint, 10, 10);
                            sheet.Cells.Merge(sint, eint, 14, 14);
                            sint = eint + 1;
                        }
                    }
                    else
                        sint += 1;
                }
                //合并日期
                //int sint1 = 3;
                //int eint1 = 0;
                //for (int i = 0; i < JH.Count - 1; i++)
                //{
                //    if (Convert.ToDateTime(JH[i].RiQi).ToString("yyyy-MM-dd") == Convert.ToDateTime(JH[i + 1].RiQi).ToString("yyyy-MM-dd") &&
                //        JH[i].RiQi != null)
                //    {
                //        eint1 = i + 1 + 3;
                //        if (i == JH.Count - 2)
                //        {
                //            sheet.Cells.Merge(sint1, eint1, 1, 1);
                //        }
                //    }
                //    else
                //    {
                //        sheet.Cells.Merge(sint1, eint1, 1, 1);
                //        sint1 = eint1 + 1;
                //    }
                //}

                xls.Save(DataSheetExport);
                DataSheetExport.Close();
                DataSheetExport.Dispose();
                SilverlightMessageBoxLibrary.Message.InfoMessage("导出成功");
            }
        }
        #endregion
    }
}
